<?php

namespace App\Admin\Extensions;

use App\Model\Moment;
use Encore\Admin\Admin;

class MomentCommentOp extends BaseAction
{
    protected function render()
    {
        Admin::script($this->script($this->actionUrl));
        $freezebtn = $this->buildButton('fail', '违规处理', ['id' => $this->id, 'status' => Moment::STATUS_BAD]);
        $okbtn = $this->buildButton('ok', '正常通过', ['id' => $this->id, 'status' => Moment::STATUS_OK]);
        $delAllbtn = $this->buildButton('fail', '删除该用户所有留言', ['id' => $this->id, 'status' => Moment::STATUS_DEL, 'action' => 'del_all']);
        $str = [''];
        if ($this->row->flag == Moment::STATUS_OK) {
            $str = [$freezebtn, $delAllbtn];
        } elseif ($this->row->flag == Moment::STATUS_BAD) {
            $str = [$okbtn, $delAllbtn];
        } else {
            $str = [$okbtn, $freezebtn, $delAllbtn];
        }
        return implode('<br/><br/>', $str);
    }
}
